package com.jbinfo.mgosql.operation.simple.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jbinfo.mgosql.operation.simple.dao.ISimpleDao;
import com.jbinfo.mgosql.operation.simple.model.SimpleDTO;
import com.jbinfo.mgosql.operation.simple.service.ISimpleService;

import net.siufung.boot.mybatis.intercetpor.Pagination;

@Service("simpleService")
@Transactional
public class SimpleServiceImpl implements ISimpleService {
	
	@Autowired
	private ISimpleDao simpleDao;
	
	@Override
	public SimpleDTO getBykey(String key) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<SimpleDTO> findList() {
		// TODO Auto-generated method stub
		return simpleDao.findList();
	}

	@Override
	public void insert(SimpleDTO simpleDto) {
		// TODO Auto-generated method stub
		simpleDao.insert(simpleDto);
	}

	@Override
	public Pagination<SimpleDTO> getPage(SimpleDTO simpleDto) {
		// TODO Auto-generated method stub
		Pagination<SimpleDTO> pager=new Pagination<SimpleDTO>(simpleDto.getPageSize(), simpleDto.getPageIndex());
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("paging", pager);
		map.put("o", simpleDto);
		List<SimpleDTO> objectList=simpleDao.queryForPage(map);
		pager.setRecords(objectList);
		return pager;
	}

}
